import { IPLAYER_DATA } from "../../../proto/proto";
import { event_on, event_dispatch } from "../../../sgame/event/EventManager";
import { PlayerEvent } from "./PlayerEvent";

export class Player {
    private _id: string;
    public get id() {
        return this._id;
    }

    private _name: string;
    public get name() {
        return this._name;
    }

    public set name(value: string) {
        this._name = value;
        event_dispatch(PlayerEvent.NAME_CHANGE, this.name);
    }

    private _coin: number;
    public get coin() {
        return this._coin;
    }

    public get coinString() {
        return this._coin.toString();
    }

    public set coin(value: number) {
        this._coin = value;
        event_dispatch(PlayerEvent.COIN_CHANGE, this.coin);
    }

    private _level: number;
    public get level() {
        return this._level;
    }

    public set level(value: number) {
        this._level = value;
        event_dispatch(PlayerEvent.LEVEL_CHANGE, this.level);
    }

    private _exp: number;
    public get exp() {
        return this._exp;
    }

    public set exp(value: number) {
        this._exp = value;
        event_dispatch(PlayerEvent.EXP_CHANGE, this.exp);
    }

    private _vip: number;
    public get vip() {
        return this._vip;
    }

    public set vip(value: number) {
        this._vip = value;
        event_dispatch(PlayerEvent.VIP_CHANGE, this.vip);
    }

    private _roomId: number;
    public get roomId() {
        return this._roomId;
    }

    public set roomId(value: number) {
        this._roomId = value;
    }

    constructor(data: IPLAYER_DATA) {
        this._id = data.id;
        this.name = data.name;
        this.coin = data.coin;
        this.level = data.level;
        this.exp = data.exp;
        this.vip = data.vip;
        this.roomId = data.roomId;
        console.log(this.exp);

        event_on("socket::gameSocketChange", () => {

        });
    }
}